<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>非父组件之间的通信-子链$refs</title>
    <script src="https://cdn.staticfile.org/vue/2.6.11/vue.js"></script>
</head>
<body>
<div id="case13-demo6">
    <a-component ref="A"></a-component>
    <b-component ref="B"></b-component>
    <button v-on:click="getChildData">我是父组件的按钮，我要拿到组件的内容</button>
    <div>{{formchild}}</div>
</div>
<script type="text/javascript">
    var case13Demo6=new Vue({
        el:"#case13-demo6",
        data:{
            formchild:"数据还未拿到"
        },
        methods:{
            getChildData:function () {
                //$refs拿来用子组件中的数据
                this.formchild=this.$refs.A.msg
            }
        },
        components:{
            'a-component':{
                template:'<div></div>',
                data: function () {
                    return{
                        msg:'我是来自A组件的内容'
                    }
                }
            },
            'b-component':{
                template: '<div></div>',
                data:function () {
                    return{
                        msg:"我是来自B组件的内容"
                    }
                }
            }
        }
    })
</script>
</body>
</html>